package com.sakuracard.stepdemo.web.controller;

import com.sakuracard.stepdemo.mapper.HomeContentMapper;
import com.sakuracard.stepdemo.model.HomeContentEntity;
import com.sakuracard.stepdemo.service.HomePageContentService;
import com.sakuracard.stepdemo.web.controller.base.BaseController;
import com.sakuracard.stepdemo.web.dto.HomePageContentDto;
import com.sakuracard.stepdemo.web.model.OperatorResult;
import com.sakuracard.stepdemo.web.model.ResponseResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;

@RestController
@RequestMapping("/homePageContent")
public class HomePageContentController extends BaseController<HomePageContentService, HomeContentEntity, HomePageContentDto> {

  public HomePageContentController(HomePageContentService service) {
    this.baseService = service;
  }

  @PutMapping("/content/{id}")
  public Object editPageContent(@PathVariable int id, @RequestParam String content) throws IOException {
    this.baseService.updatePageContent(id, content);
    return ResponseResult.success(new OperatorResult((long) id));
  }
}
